/*  ------------------------------------------------------------------------
	 NQ Common Services Library
	 
	 Homepage: http://www.awzhome.de/
	 ------------------------------------------------------------------------
	 
	 The contents of this file are subject to the Mozilla Public License
	 Version 1.1 (the "License"); you may not use this file except in
	 compliance with the License. You may obtain a copy of the License at
	 http://www.mozilla.org/MPL/
	 
	 Software distributed under the License is distributed on an "AS IS"
	 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	 License for the specific language governing rights and limitations
	 under the License.
	
	 The Original Code is code of NQ Common Services Library.

	 The Initial Developer of the Original Code is Andreas Weizel.
	 Portions created by the Initial Developer are
	 Copyright (C) 2006-2012 Andreas Weizel. All Rights Reserved.
	 
	 Contributor(s): (none)
	 
	 Alternatively, the contents of this file may be used under the terms
	 of the GNU General Public License Version 2.0 or later (the "GPL"),
	 or the GNU Lesser General Public License Version 2.1 or later (the
	 "LGPL"), in which case the provisions of the GPL or the LGPL are
	 applicable instead of those above. If you wish to allow use of your
	 version of this file only under the terms of the GPL or the LGPL and
	 not to allow others to use your version of this file under the MPL,
	 indicate your decision by deleting the provisions above and replace
	 them with the notice and other provisions required by the GPL or the
	 LGPL. If you do not delete the provisions above, a recipient may use
	 your version of this file under the terms of any of the MPL, the GPL
	 or the LGPL.
	 ------------------------------------------------------------------------
*/

using AWZhome.NQ.Core;
using System;

namespace AWZhome.NQ.CommonServices
{
	/// <summary>
	/// Interface for view controller services.
	/// </summary>
	public interface IView
	{
		/// <summary>
		/// Returns the internal (unique) name of the view.
		/// </summary>
		string Name
		{
			get;
		}

		/// <summary>
		/// Returns the view's context (name of open file, open chatroom etc.).
		/// </summary>
		string Context
		{
			get;
		}

		/// <summary>
		/// Returns the display name of the view.
		/// </summary>
		string DisplayName
		{
			get;
		}

		/// <summary>
		/// Returns the tool tip shown when moving mouse cursor over the view's title or tab.
		/// </summary>
		string ToolTip
		{
			get;
		}

		/// <summary>
		/// Returns whether the view should be highlighted to indicate that something important has happened in the view.
		/// </summary>
		/// <remarks>
		/// This flag will be automatically reset by view manager when the view becomes active.
		/// </remarks>
		bool IsChanged
		{
			get;
		}

		/// <summary>
		/// Returns whether the view has the "dirty" flag indicating documents with unsaved changes.
		/// </summary>
		bool IsDirty
		{
			get;
		}

		/// <summary>
		/// Returns whether the view may be closed by user.
		/// </summary>
		bool CanBeClosed
		{
			get;
		}

		/// <summary>
		/// Returns whether the contents of the view should be saved in some sort of history storage (e.g. for chat sessions).
		/// </summary>
		bool IsLoggable
		{
			get;
		}

		/// <summary>
		/// Returns whether view is a document view. Shouldn't be used any more.
		/// </summary>
		bool IsDocument
		{
			get;
		}

		/// <summary>
		/// Returns whether an open view should be persisted when its container is closed.
		/// It will be restored when container is opened for the next time.
		/// </summary>
		bool IsPersisted
		{
			get;
		}

		/// <summary>
		/// Returns the visual object (i.e. control instance) shown in the view.
		/// </summary>
		/// <remarks>
		/// It depends on implementation of view manager, whether this control should be
		/// WPF, Windows Forms or something else.
		/// </remarks>
		object DisplayedObject
		{
			get;
		}

		/// <summary>
		/// Returns the view's icon to be shown in UI.
		/// </summary>
		System.Windows.Media.ImageSource Icon
		{
			get;
		}

		/// <summary>
		/// Returns the display modes possible for this view. This determines
		/// where the view is allowed do be docked in container window.
		/// </summary>
		ViewDisplayMode DockingType
		{
			get;
		}

		/// <summary>
		/// Sets or retrieves the view's current display mode
		/// (i.e. dock direction in container window).
		/// </summary>
		ViewDisplayMode DisplayMode
		{
			get;
			set;
		}

		/// <summary>
		/// Sets or retrieves the position index of the view.
		/// </summary>
		int Position
		{
			get;
			set;
		}

		/// <summary>
		/// Sets or retrieves the instance of view manager service,
		/// this view is assigned to.
		/// </summary>
		IViewManager ViewManager
		{
			get;
			set;
		}

		/// <summary>
		/// Returns the session service instance this view belongs to.
		/// </summary>
		ISession Session
		{
			get;
		}

		/// <summary>
		/// Initializes the view.
		/// </summary>
		/// <param name="context">
		/// Context to be preset
		/// (<see cref="AWZhome.NQ.CommonServices.IView.Context"/> property).
		/// </param>
		/// <remarks>
		/// In this method the view must generate a unique internal name, so it
		/// can expose it through <see cref="AWZhome.NQ.CommonServices.IView.Name"/>
		/// property after the method call. To ensure the name unique throughout all
		/// containers, you can use
		/// <see cref="AWZhome.NQ.CommonServices.IContainerManager.GenerateViewName"/>
		/// method.
		/// </remarks>
		void Initialize(string context);

		/// <summary>
		/// Method called by view manager when the view becomes active.
		/// </summary>
		/// <param name="oldView">
		/// Instance of the view being active before,
		/// or <c>null</c>, if no view has been active.
		/// </param>
		void Activate(IView oldView);

		/// <summary>
		/// Method called by view manager when the view becomes inactive.
		/// </summary>
		/// <param name="newView">
		/// Instance of the new view being active now,
		/// or <c>null</c>, if no view became active.
		/// </param>
		void Deactivate(IView newView);

		/// <summary>
		/// Requests the view to decide if it can be closed.
		/// </summary>
		/// <returns>
		/// If <c>true</c>, the view will be closed by view manager,
		/// otherwise closing will be ignored.
		/// </returns>
		bool RequestClosing();

		/// <summary>
		/// Requests the view to load its contents and configuration.
		/// </summary>
		void LoadContents();

		/// <summary>
		/// Requests the view to save its configuration/state.
		/// </summary>
		/// <param name="saveReason">Specifies the reason for saving request.</param>
		void SaveContents(ViewSaveReason saveReason);

		/// <summary>
		/// Called by bar service, when a menu or toolbar item is clicked
		/// while the view is active.
		/// </summary>
		/// <param name="barItem">Instance of clicked menu or toolbar item.</param>
		void BarItemClicked(IBarItem barItem);
	}
}
